using System;
using System.Collections.Generic;
using System.Text;
using XProject.Entity;
using System.Data.OleDb;

namespace XProject.DAO
{
    class PhoneTypeDAO:DBAccess
    {
        #region sql command
        //string SQL_SELECT_ID = "select max(TypeID) from PhoneType";
        string SQL_SELECT_ALL = "select * from PhoneType";
        //string SQL_INSERT = "Insert into PhoneType(TypeName) values(@typename)";
        //string SQL_UPDATE = "update phoneType set TypeName=@typename";
        //string SQL_DELETE = "delete from PhoneType where TypeID=@typeID";
        #endregion
        string message;
        public string Message
        {
            get { return message; }
            set { message = value; }
        }
        public IList<PhoneType> SelectAll()
        {
            IList<PhoneType> list = new List<PhoneType>();
            try
            {
                OleDbCommand command = new OleDbCommand(SQL_SELECT_ALL, conn);
                if (Connect())
                {
                    OleDbDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        PhoneType type = new PhoneType();
                        type.TypeID = dr.GetByte(0);
                        type.TypeName = dr.GetString(1);
                        list.Add(type);
                    }
                }
            }
            catch (OleDbException ex)
            {
                message = ex.Message;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return list;
        }
        public int Insert(PhoneType type)
        {
            return 0;
        }
        
    }
}
